package com.example.yunxinagyue

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.yunxinagyue.databinding.ActivityFramlayoutBinding
import com.google.android.material.bottomnavigation.BottomNavigationView

class FramlayoutActivity : AppCompatActivity() {
    private lateinit var binding: ActivityFramlayoutBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityFramlayoutBinding.inflate(layoutInflater)
        setContentView(binding.root)
        val mine = MineFragment.newInstance()
        val recommend = RecommendFragment.newInstance()
        val msg = MsgFragment.newInstance()
        val focus = FocusFragment.newInstance()
        val community = CommunityFragment.newInstance()
        val actionBar=supportActionBar
        if(actionBar!=null){
//            设置ActionBar是否显示返回键
            actionBar.setDisplayHomeAsUpEnabled(false)
//            设置是否显示标题
            actionBar.setDisplayShowTitleEnabled(false)
        }
        supportFragmentManager.beginTransaction().add(R.id.frame2,mine).commit()
        val bottom = findViewById<BottomNavigationView>(R.id.bottom2)
        bottom.itemIconTintList=null
        bottom.setOnItemSelectedListener {
            when(it.itemId){
                R.id.community->supportFragmentManager.beginTransaction()
                    .replace(R.id.frame2,community).commit()
                R.id.focus -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame2,focus).commit()
                R.id.mine -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame2,mine).commit()
                R.id.recommend -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame2,recommend).commit()
                R.id.msg -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame2,msg).commit()
            }
            true
        }
        actionBar?.hide()

    }
}